# -*- coding = utf-8 -*-
# @Time    : 2025/3/28 下午8:19
# @Author  : yqk
# @File    : 多线程共享全局变量.py
# @Software: PyCharm
import threading
lock = threading.Lock()
a = 0
def add_value(num):
    global a
    lock.acquire()
    for i in range(num):
        a += 1
    lock.release()
    print(f'A:{a}')

def main():
    for i in range(10):
        t = threading.Thread(target=add_value,args=(1000000,))
        t.start()
if __name__ == '__main__':
    main()